home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
UUPC11QS.ARJ
/
RNEWS.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-12-07
|
3KB
|
94 lines
/*
r n e w s
Receive incoming news into the news directory.
This procedure needs to be rewritten to perform real news
processing. Next release(?)
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <fcntl.h>
#include <io.h>
#include "lib.h"
#include "hlib.h"
#include "timestmp.h"
#ifdef __TURBOC__
#pragma argsused
#endif
currentfile();
void main( int argc, char **argv)
{
int count = 1;
unsigned chars_read;
char filename[FILENAME_MAX], format[FILENAME_MAX], buf[BUFSIZ];
FILE *f;
long now = time(nil(long));
#if defined(__CORE__)
#error This file cannot be compiled with __CORE__ enabled!!!
#endif
banner( argv );
if (!configure( B_NEWS ))
panic(); /* system configuration failed */
mkfilename(filename, spooldir, LOGFILE);
if ((logfile = FOPEN(filename, "a", BINARY)) == nil(FILE))
{
fprintf(stderr,"%s: Cannot open %s, program terminating\n",
argv[0], filename);
exit( 3 );
} /* if */
tzset(); /* Set up time zone information */
/*--------------------------------------------------------------------*/
/* Get output file name */
/*--------------------------------------------------------------------*/
mkfilename(format, newsdir, "%08.8lX.%03.3d"); /* make pattern first */
do {
sprintf(filename, format, now, count++); /* build real file name */
f = fopen(filename,"r");
if (f != NULL) /* Does the file exist? */
fclose(f); /* Yes --> Close the stream */
} while (f != NULL);
printmsg(6, "rnews: Delivering incoming news into %s", filename);
if ((f = FOPEN(filename, "w", BINARY)) == nil(FILE))
{
printmsg(0, "rnews: cannot open input");
printerr(filename);
exit(2);
}
/*--------------------------------------------------------------------*/
/* Main loop to write the file out */
/*--------------------------------------------------------------------*/
setmode(fileno(stdin), O_BINARY); /* Don't die on control-Z, etc */
while ((chars_read = fread(buf,sizeof(char), BUFSIZ, stdin)) != 0) /* wt */
fwrite(buf,sizeof(char),chars_read,f); /* wt */
/*--------------------------------------------------------------------*/
/* Close open files and exit */
/*--------------------------------------------------------------------*/
fclose(f);
fclose(logfile);
exit(0);
} /*main*/